package com.my.zidingyikongjian.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.my.zidingyikongjian.R;

public class SplishActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splish);
        initVeiw();
    }

    private void initVeiw() {
        findViewById(R.id.btn_circle_sh).setOnClickListener(this);
        findViewById(R.id.btn_Line_sh).setOnClickListener(this);
        findViewById(R.id.btn_more_Line_sh).setOnClickListener(this);
        findViewById(R.id.btn_move_Line_sh).setOnClickListener(this);
        findViewById(R.id.btn_point_sh).setOnClickListener(this);
        findViewById(R.id.btn_more_points_sh).setOnClickListener(this);
        findViewById(R.id.btn_rect_sh).setOnClickListener(this);
        findViewById(R.id.btn_round_rect_sh).setOnClickListener(this);
        findViewById(R.id.btn_oval_sh).setOnClickListener(this);
        findViewById(R.id.btn_arc_sh).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_circle_sh: // 画圆
                goIntent(MainActivity.class);
                break;
            case R.id.btn_Line_sh: // 画单条线
                goIntent(DrawLineActivity.class);
                goLineIntent(0);
                break;
            case R.id.btn_more_Line_sh: // 画多条线
                goIntent(DrawLineActivity.class);
                goLineIntent(1);
                break;
            case R.id.btn_move_Line_sh: // 移动的线
                goIntent(DrawLineActivity.class);
                goLineIntent(2);
                break;
            case R.id.btn_point_sh: // 画点
                goIntent(DrawLineActivity.class);
                goLineIntent(3);
                break;
            case R.id.btn_more_points_sh: // 画多个点
                goIntent(DrawLineActivity.class);
                goLineIntent(4);
                break;
            case R.id.btn_rect_sh: // 矩形
                goIntent(DrawLineActivity.class);
                goLineIntent(5);
                break;
            case R.id.btn_round_rect_sh: // 矩形
                goIntent(DrawLineActivity.class);
                goLineIntent(6);
                break;
            case R.id.btn_oval_sh: // 矩形
                goIntent(DrawLineActivity.class);
                goLineIntent(7);
                break;
                case R.id.btn_arc_sh: // 弧
                goIntent(DrawLineActivity.class);
                goLineIntent(8);
                break;
        }
    }

    /**
     * 画线
     *
     * @param flag 0 一条直线，1多条线,2移动的线
     */
    private void goLineIntent(int flag) {
        Intent intent = new Intent(SplishActivity.this, DrawLineActivity.class);
        intent.putExtra("draw_line", "" + flag);
        startActivity(intent);
    }

    /**
     * 跳转页面
     */
    private void goIntent(Class cla) {
        Intent intent = new Intent(SplishActivity.this, cla);
        startActivity(intent);
    }
}
